package com.li.core.controller.system;

import com.li.configserve.config.syslog.SysLog;
import com.li.configserve.controller.BaseController;
import com.li.configserve.domain.gloabreturn.PageInfoVO;
import com.li.configserve.domain.gloabreturn.ResponseInfo;
import com.li.core.domain.system.Menu;
import com.li.core.domain.system.MenuVO;
import com.li.core.service.system.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2021年11月21日 17:05:00
 */
@RequestMapping("/menu")
@RestController
@Api(tags = "{菜单相关 Controller}")
public class MenuController extends BaseController {

    @Autowired
    private MenuService menuService;

    @SysLog
    @ApiOperation(value = "菜单查询接口")
    @GetMapping("/get/{id}")
    public ResponseInfo<List<MenuVO>> listMenuByUserId(@PathVariable(value = "id") String id) {
        return menuService.listMenuByUserId(id);
    }

    @ApiOperation(value = "菜单分页接口")
    @PostMapping("/page")
    public PageInfoVO<MenuVO> listPageMenuVo() {
        return menuService.listPageMenuVo(getPageParam(request));
    }


    @ApiOperation(value = "保存修改")
    @RequestMapping("/save")
    public ResponseInfo<Menu> saveOrEditMenu(Menu menu) {
        return menuService.saveOrEditMenu(menu);
    }

}
